package com.woniuxy.sales.model.vo;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 购物车项
 */
@Data
@NoArgsConstructor
public class CartItemVo {

    private Integer userId;  //用户id
    private Integer goodsId;   //商品id

    private String name;   //商品名
    private String imgSrc;  //图书图片
    private Double price;   //单价

    private Integer quantity; //数量
    private Double sumPrice; //金额

    //带部分参数的构造器
    public CartItemVo(Integer userId, Integer goodsId, String name, String imgSrc, Double price, Integer quantity) {
        this.userId = userId;
        this.goodsId = goodsId;
        this.name = name;
        this.imgSrc = imgSrc;
        this.price = price;
        this.quantity = quantity;
    }

    //计算金额的方法
    public Double getSumPrice() {
        return price * quantity;
    }
}